package fr.cnam.ratpProject.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class SQLiteJdbc {
	
	private Connection c;
	
	private static SQLiteJdbc INSTANCE = null;
	
	private SQLiteJdbc(){
		c = null;
		try {
			Class.forName("org.sqlite.JDBC");
		    c = DriverManager.getConnection("jdbc:sqlite:ratp_project.sqlite");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}	
	
	public static SQLiteJdbc getInstance(){
		if(INSTANCE == null)
			return new SQLiteJdbc();
		else
			return INSTANCE;
	}
	
	public Statement getStatement(){
		try {
			return c.createStatement();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
}
